import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../i18n.dart';
import 'controller.dart';
import '/router.dart' as router;

class Home extends StatelessWidget {
  @override
  Widget build(context) {
    // 使用Get.put()实例化你的类，使其对当下的所有子路由可用。
    final HomeController homeController = Get.put(HomeController());

    return Scaffold(
        // 使用Obx(()=>每当改变计数时，就更新Text()。
        // appBar:
        //     AppBar(title: Obx(() => Text("Clicks: ${homeController.count}"))),

        // 用一个简单的Get.to()即可代替Navigator.push那8行，无需上下文！
        body: Center(
            child: Column(
              children: [
                Padding(padding: EdgeInsets.symmetric(vertical: 10),
                    child:    ElevatedButton(
                      child: Text("logout".tr),
                      onPressed: () => Get.toNamed(router.loginRouterPath)
                    )
                ),

                Padding(padding: EdgeInsets.symmetric(vertical: 10),
                    child:    ElevatedButton(
                        child: Text("changeTheme".tr),
                        onPressed: () => Get.changeTheme(Get.isDarkMode ? ThemeData.light() : ThemeData.dark())
                )),

                Padding(padding: EdgeInsets.symmetric(vertical: 10),
                    child:    ElevatedButton(
                      child: Text("changeLanguage".tr),
                      onPressed: changeLanguage
                ))

              ],
        )),
        floatingActionButton: FloatingActionButton(
            child: Icon(Icons.add), onPressed: homeController.increment));
  }
}
